<?php
error_reporting(0);
$id = isset($_GET['id'])?$_GET['id']:'bjws';
$fmt = isset($_GET['fmt'])?$_GET['fmt']:'';//默认hls;flv
$n = [
    'bjws' => 'djsofjs183', //北京卫视
    'bjwy' => 'wnkjnakjd', //北京文艺(无效)
    'bjjskj' => 'miih88', //纪实科教
    'bjtyxx' => 'rtyjgas', //体育休闲(无效)
    'bjys' => 'drtctv', //北京影视
    'bjcj' => 'mouibyu', //北京财*
    'bjxw' => 'bncdte7', //北京新闻
    'bjsh' => 'jmnetfg', //北京生活
    'bjkk' => 'ijlbmlsi394', //北京卡酷
    'brtv8k' => '8kliveok', // BRTV8K
    ];
$arr1 = [138,188,193,197,200,205,212,211,233,216,222,224,132,239,250,236,244];
$ip1 = "1.180.234.".$arr1[array_rand($arr1)];
$arr2 = [23,6,17,29,31,21,16,82,81,99,87,95,90,100,148,158];
$ip2 = "42.236.89.".$arr2[array_rand($arr2)];
$arr3 = [28,49,24,129,145,155,180,184,187];
$ip3 = "58.216.17.".$arr3[array_rand($arr3)];
$arr4 = [131,138,130];
$ip4 = "122.228.82.".$arr4[array_rand($arr4)];
$arr5 = [35,91,164,170,163,166,180];
$ip5 = "182.247.251.".$arr5[array_rand($arr5)];
$arr6 = [11,31,40,42,33,17,26,22,143,145,147,142,160,159,165,163,144,149,232];
$ip6 = "183.204.12.".$arr6[array_rand($arr6)];
$arr7 = [13,84,97,131,170,185,237];
$ip7 = "183.204.13.".$arr7[array_rand($arr7)];
$arr8 = [105,125,138,152,157,162,169,173,140,208,202,207,198,219,220,242,239,217];
$ip8 = "223.111.191.".$arr8[array_rand($arr8)];

$arr = [$ip1,$ip2,$ip3,$ip4,$ip5,$ip6,$ip7,$ip8];
$ip = $arr[array_rand($arr)];

$d = json_decode(file_get_contents('http://btv8kappvms.interway.com.cn/tvradio/tv/getTvInfo?tv_id=3'),1);
$flv = "http://{$ip}/downflv.brtvcloud.com/live/{$n[$id]}.flv?".parse_url($d['data']['m3u8'])['query'];
$m3u8  = preg_replace('|\.flv|','.m3u8',$flv);
if($fmt == ''||$fmt == 'hls'){
   header('location:'.$m3u8);
   //echo $m3u8;
   }
if($fmt == 'flv'){
   header('location:'.$flv);
   //echo $flv;
   }
?>